layout.tsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import clsx from "clsx";
  2. import { Viewport } from "next";
  3. import { NextIntlClientProvider } from "next-intl";
  4. import { getMessages } from "next-intl/server";
  5. import { Inter as FontSans } from "next/font/google";
  6. import { ReactNode } from "react";
  7. import "../globals.scss";
  8. import { Providers } from "./providers";
  9. // 加载字体
  10. const fontSans = FontSans({
  11. subsets: ["latin"],
  12. variable: "--font-sans",
  13. });
  14. export const viewport: Viewport = {};
  15. export const metadata = {
  16. keywords: ["Next.js"],
  17. description: "Next.js",
  18. appleWebApp: {
  19. statusBarStyle: "black",
  20. },
  21. formatDetection: {
  22. email: false,
  23. address: false,
  24. telephone: false,
  25. },
  26. referrer: "no-referrer",
  27. other: {
  28. viewport: [
  29. "width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0," +
  30. " viewport-fit=cover ",
  31. ],
  32. },
  33. };
  34. console.log(
  35. `🚀🚀🚀🚀🚀-> in layout.tsx on 38`,
  36. process.env.NODE_ENV,
  37. process.env.NEXT_PUBLIC_BASE_URL
  38. );
  39. export default async function LocaleLayout({
  40. children,
  41. params: { locale },
  42. }: {
  43. children: ReactNode;
  44. params: { locale: string };
  45. }) {
  46. const messages = await getMessages();
  47. return (
  48. <html lang={locale} suppressHydrationWarning>
  49. <body className={clsx("font-sans", fontSans.variable)}>
  50. <NextIntlClientProvider messages={messages}>
  51. <Providers themeProps={{ attribute: "class" }}>{children}</Providers>
  52. </NextIntlClientProvider>
  53. </body>
  54. </html>
  55. );
  56. }